home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / bsd / ufs / quotas.h < prev   
C/C++ Source or Header  |  1995-02-14  |  5KB  |  136 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  **********************************************************************
  7.  * HISTORY
  8.  * 25-Jan-89  Peter King (king) at NeXT
  9.  *    NFS 4.0 Changes.
  10.  *
  11.  * 27-Aug-87  Peter King (king) at NeXT
  12.  *    Original Sun source, ported to Mach.
  13.  *
  14.  **********************************************************************
  15.  */ 
  16.  
  17. /*    @(#)quota.h    2.1 88/05/20 4.0NFSSRC SMI    */
  18.  
  19. /* 
  20.  * Copyright (c) 1988 by Sun Microsystems, Inc.
  21.  * @(#) from SUN 2.10
  22.  */
  23.  
  24.  
  25. /*
  26.  * Various junk to do with various quotas (etc) imposed upon
  27.  * the average user (big brother finally hits UNIX).
  28.  */
  29.  
  30. /*
  31.  * The following constants define the default amount of time given a user
  32.  * before the soft limits are treated as hard limits (usually resulting
  33.  * in an allocation failure). These may be  modified by the quotactl
  34.  * system call with the Q_SETQLIM or Q_SETQUOTA commands.
  35.  */
  36.  
  37. #define    DQ_FTIMELIMIT    (7 * 24*60*60)        /* 1 week */
  38. #define    DQ_BTIMELIMIT    (7 * 24*60*60)        /* 1 week */
  39.  
  40. /*
  41.  * The dqblk structure defines the format of the disk quota file
  42.  * (as it appears on disk) - the file is an array of these structures
  43.  * indexed by user number.  The setquota sys call establishes the inode
  44.  * for each quota file (a pointer is retained in the mount structure).
  45.  */
  46.  
  47. struct    dqblk {
  48.     u_long    dqb_bhardlimit;    /* absolute limit on disk blks alloc */
  49.     u_long    dqb_bsoftlimit;    /* preferred limit on disk blks */
  50.     u_long    dqb_curblocks;    /* current block count */
  51.     u_long    dqb_fhardlimit;    /* maximum # allocated files + 1 */
  52.     u_long    dqb_fsoftlimit;    /* preferred file limit */
  53.     u_long    dqb_curfiles;    /* current # allocated files */
  54.     u_long    dqb_btimelimit;    /* time limit for excessive disk use */
  55.     u_long    dqb_ftimelimit;    /* time limit for excessive files */
  56. };
  57.  
  58. #define dqoff(UID)    ((off_t)((UID) * sizeof(struct dqblk)))
  59.  
  60. /*
  61.  * The dquot structure records disk usage for a user on a filesystem.
  62.  * There is one allocated for each quota that exists on any filesystem
  63.  * for the current user. A cache is kept of recently used entries.
  64.  * Active inodes have a pointer to the dquot associated with them.
  65.  */
  66. struct    dquot {
  67.     struct    dquot *dq_forw, *dq_back;/* hash list, MUST be first entry */
  68.     struct    dquot *dq_freef, *dq_freeb; /* free list */
  69.     short    dq_flags;
  70. #define DQ_LOCKED    0x01        /* locked for I/O */
  71. #define DQ_WANT        0x02        /* wanted */
  72. #define    DQ_MOD        0x04        /* this quota modified since read */
  73. #define    DQ_BLKS        0x10        /* has been warned about blk limit */
  74. #define    DQ_FILES    0x20        /* has been warned about file limit */
  75.     short    dq_cnt;            /* count of active references */
  76.     short    dq_uid;            /* user this applies to */
  77.     struct mount *dq_mp;        /* filesystem this relates to */
  78.     struct dqblk dq_dqb;        /* actual usage & quotas */
  79. };
  80.  
  81. #define    dq_bhardlimit    dq_dqb.dqb_bhardlimit
  82. #define    dq_bsoftlimit    dq_dqb.dqb_bsoftlimit
  83. #define    dq_curblocks    dq_dqb.dqb_curblocks
  84. #define    dq_fhardlimit    dq_dqb.dqb_fhardlimit
  85. #define    dq_fsoftlimit    dq_dqb.dqb_fsoftlimit
  86. #define    dq_curfiles    dq_dqb.dqb_curfiles
  87. #define    dq_btimelimit    dq_dqb.dqb_btimelimit
  88. #define    dq_ftimelimit    dq_dqb.dqb_ftimelimit
  89.  
  90. /*
  91.  * flags for m_qflags in mount struct
  92.  */
  93. #define MQ_ENABLED    0x01        /* quotas are enabled */
  94.  
  95. #if defined(KERNEL) && defined(QUOTA)
  96. struct    dquot *dquot, *dquotNDQUOT;
  97. int    ndquot;
  98.  
  99. extern void qtinit();            /* initialize quota system */
  100. extern struct dquot *getinoquota();    /* establish quota for an inode */
  101. extern int chkdq();            /* check disk block usage */
  102. extern int chkiq();            /* check inode usage */
  103. extern void dqrele();            /* release dquot */
  104. extern int closedq();            /* close quotas */
  105.  
  106. extern int getdiskquota();        /* get dquot for uid on filesystem */
  107. extern void dqput();            /* release locked dquot */
  108. extern void dqupdate();            /* update dquot on disk */
  109.  
  110. #define DQLOCK(dqp) { \
  111.     while ((dqp)->dq_flags & DQ_LOCKED) { \
  112.         (dqp)->dq_flags |= DQ_WANT; \
  113.         (void) sleep((caddr_t)(dqp), PINOD+1); \
  114.     } \
  115.     (dqp)->dq_flags |= DQ_LOCKED; \
  116. }
  117.  
  118. #define DQUNLOCK(dqp) { \
  119.     (dqp)->dq_flags &= ~DQ_LOCKED; \
  120.     if ((dqp)->dq_flags & DQ_WANT) { \
  121.         (dqp)->dq_flags &= ~DQ_WANT; \
  122.         wakeup((caddr_t)(dqp)); \
  123.     } \
  124. }
  125. #endif KERNEL && QUOTA
  126.  
  127. /*
  128.  * Definitions for the 'quotactl' system call.
  129.  */
  130. #define Q_QUOTAON    1    /* turn quotas on */
  131. #define Q_QUOTAOFF    2    /* turn quotas off */
  132. #define    Q_SETQUOTA    3    /* set disk limits & usage */
  133. #define    Q_GETQUOTA    4    /* get disk limits & usage */
  134. #define    Q_SETQLIM    5    /* set disk limits only */
  135. #define    Q_SYNC        6    /* update disk copy of quota usages */
  136.